#ifndef ODN_NETWORKING_H
#define ODN_NETWORKING_H

#include <RakNet\RakPeerInterface.h>
#include <RakNet\RakServerInterface.h>
#include <RakNet\RakClientInterface.h>
#include <RakNet\RakNetworkFactory.h>
#include <RakNet\BitStream.h>
#include <RakNet\Multiplayer.h>

#include <iostream>

#include "ODN_String.h"

namespace ouden {
	
	//typedef RakClientInterface ClientInterface;
	//typedef RakServerInterface ServerInterface;
	
	//Inherit from these to implement client and server packet handling
	typedef Multiplayer<RakClientInterface> MultiplayerClient;
	typedef Multiplayer<RakServerInterface> MultiplayerServer;

class INetworkInterface
{
	
public:
	
	virtual void processPackets() = 0;
	
};

class CClientInterface
{
public:
	
	CClientInterface(MultiplayerClient* pPacketHandler, String sHostAddress, unsigned short iServerPort, unsigned short iClientPort);
	~CClientInterface();
	
	void processPackets() 		{ m_pPacketHandler->ProcessPackets(m_pClient); }
	//TODO: Decide whether need this  virtual void send(char* btBitStream, long iLength);
	RakClientInterface* getNetworkInterface() 		{ return m_pClient; }
	
protected:
	
private:
	
	RakClientInterface* 	m_pClient; 			//Instance of the actual RakNet client interface
	MultiplayerClient* 		m_pPacketHandler; 	//Pointer to the packet handler
	
};

class CServerInterface
{
public:
	
	CServerInterface(MultiplayerServer* pPacketHandler, unsigned short iMaxPlayers, unsigned short iServerPort);
	~CServerInterface();
	
	void processPackets() 		{ m_pPacketHandler->ProcessPackets(m_pServer); }
	//TODO: Decide whether need this  virtual void send(char* btBitStream, long iLength);
	RakServerInterface* getNetworkInterface() 		{ return m_pServer; }
	
protected:
	
private:
	
	RakServerInterface* 	m_pServer; 			//Instance of the actual RakNet server interface
	MultiplayerServer* 		m_pPacketHandler; 	//Pointer to the packet handler
	
};

} //namespace ouden

//TODO: Remove all the stuff below when finished testing
#endif // ODN_NETWORKING_H
